<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <title>{$Think.config.website.name}</title>
    <link rel="stylesheet" href="__WECHAT__/css/weui.min.css">
    <link rel="stylesheet" href="__WECHAT__/css/weui-common.css">
</head>
<body ontouchstart>
<div class="container" id="container">
    <div class="page input js_show">
        <div class="page__hd">
            <h1 class="page__title">{$Think.config.website.name}</h1>
            <p class="page__desc">注册</p>
        </div>

        <div class="page__bd">
            <div class="weui-cells__title">帐号注册</div>
            <div class="weui-cells weui-cells_form">
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">
                            用户名
                        </label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input nickname" placeholder="请输入用户名" type="text">
                        </input>
                    </div>
                </div>

                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <label class="weui-label">
                            密码
                        </label>
                    </div>
                    <div class="weui-cell__bd">
                        <input class="weui-input password" placeholder="请输入密码" type="text">
                        </input>
                    </div>
                </div>
            </div>
            <div class="weui-flex">
                <div class="weui-flex__item">
                    <a href="javascript:void(0);" class="weui-btn weui-btn_primary reg">注册帐号</a>

                </div>
            </div>

            <!--微信-->
            <div class="weui-cells__title">已有账号，点击登录</div>
            <a href="{:url('wechat/Auth/login')}" class="weui-btn weui-btn_plain-primary">帐号登录</a>

        </div>
    </div>

</div>
</body>
<script src="__WECHAT__/js/jquery.min.js"></script>
<script src="__WECHAT__/vendors/layer/layer.js"></script>
<script type="text/javascript">
$(function () {
    var reg_url = '{:url('wechat/Auth/reg')}';
    var login_url = '{:url('wechat/Auth/login')}';
    $('.reg').click(function () {
        var nickname = $('.nickname').val();
        var password = $('.password').val();

        if((nickname == '')||( password == '')){
            layer.open({
                content: '用户名或密码不能为空',
                skin: 'msg',
                time: 1.5,
            });
        }else{
            $.post(reg_url,{nickname:nickname , password: password},function (result) {
                if(result.code == 200){
                    layer.open({
                        content: result.message,
                        skin: 'msg',
                        time: 1.5,
                        end: function () {
                            window.location.href = login_url;
                        }
                    });
                }else{
                    layer.open({
                        content: result.message,
                        skin: 'msg',
                        time: 1.5,
                    });
                }
            });
        }

    });

});
</script>
</html>